<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="Resource/layui/css/layui.css" media="all">
    <script src="Resource/jquery-3.3.1.js"></script>
    <style>
        #tab tr td{
            padding-top:10px;
            padding-left: 10px;
        }
        #xgdiv .layui-input{
           width: 140px;
           height: 30px;
        }
        #tab{
            margin-top: 5px;
            margin-left: 30px;
        }

        #image {
            position: absolute;
            top: -40px;
            left: 350px;
            background: url(image/icon2.png);
            width: 400px;
            height: 400px;
        }
        #foot{
            height: 50px;
            align-content: center;
            background: white;
        }
        #foot input{
            margin-left: 300px;
            margin-top: 10px;
        }
    </style>
</head>
<body>
<table class="layui-hide" id="test" lay-filter="test"></table>
<div style="display:none;background-repeat:no-repeat;" id="xgdiv">
    <form action="./updateFund" method="post">
        <div id="image" style="background-repeat:no-repeat;text-align: center;">
        </div>
        <div id="image2" style="background-repeat:no-repeat;text-align: center;">
        </div>
        <center>
            <table style="width: 800px;
            height: 500px;
            overflow-x: scroll;
            overflow-y: hidden;
            background-color: white;" class="layui-form" id="tab">
                <tr>
                    <td>基金编号：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input class="layui-input" name="fId" id="edit_fId" readonly="readonly" type="text"
                                   required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>基金名称：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input class="layui-input" name="fName" id="edit_fName" type="text" required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>原费率：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input class="layui-input" name="beforeRate" id="edit_beforeRate" type="text" required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>现费率：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input  class="layui-input" name="afterRate" id="edit_afterRate" type="text" required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>最小申购额：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input class="layui-input" name="minBuy" id="edit_minBuy" type="text" required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>一年收益：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input  class="layui-input" name="sy1n" id="edit_sy1n" type="text" required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>六月收益：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input  class="layui-input" name="sy6y" id="edit_sy6y" type="text" required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>三月收益：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input  class="layui-input" name="sy3y" id="edit_sy3y" type="text" required>
                        </div>
                    </td>

                    <td style=" position: absolute;
                           top: 427px;
                            left: 389px;">数据截止日期：</td>
                    <td  style="position: absolute;
                            top: 421px;
                            left: 524px;">
                        <div class="layui-input-inline">
                            <input  class="layui-input" style="width: 150px;" name="endTime" id="edit_endTime" type="text" required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>一月收益：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input  class="layui-input" name="sy1y" id="edit_sy1y" type="text" required>
                        </div>
                    </td>
                    <td style="position: absolute;
                         top: 383px;
                         left: 388px;">估值时间：</td>
                    <td style="position: absolute;
                        top: 383px;
                        left: 523px;">
                        <div class="layui-input-inline">
                            <input  class="layui-input" style="width: 150px;" name="valuationTime" id="edit_valuationTime" type="text" required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>单位净值：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input  class="layui-input" name="dwjz" id="edit_dwjz" type="text" required>
                        </div>
                    </td>
                    <td style="position: absolute;
                            top: 345px;
                            left: 387px">单位估值：</td>
                    <td style="position: absolute;
                         top: 341px;
                            left: 523px;
                        }">
                        <div class="layui-input-inline">
                            <input  class="layui-input" name="dwgz" id="edit_dwgz" type="text" required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td >实时净资产：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input  class="layui-input" name="nowWorth" id="edit_nowWorth" type="text" required>
                        </div>
                    </td>
                    <td style="position: absolute;
                               top: 301px;
                               left: 388px;">是否能够代销：</td>
                    <td style="position: absolute;
                           top: 296px;
                            left: 523px;">
                        <div class="layui-input-inline">
                            <input  class="layui-input" name="ifBuy" id="edit_ifBuy" type="text" required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>持仓股票代码：</td>
                    <td>
                        <div class="layui-input-inline">
                            <input class="layui-input" style="width: 570px" name="stockCode" id="edit_stockCode" type="text" required>
                        </div>
                    </td>
                </tr>
            </table>
        </center>
        <div id="foot">
            <input style="width: 250px;background: #364150" class="layui-btn" type="submit" value="修改" />
        </div>
    </form>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
    <!-- 表单元素 -->
    <table style="margin-top: 40px;">
        <tr>
            <td>
                <div class="layui-form-item" style="width: 280px;">
                    <label style="width: 130px;" class="layui-form-label">基金编号</label>
                    <div class="layui-input-block">
                        <input type="text" style="width: 150px;" name="fId" required lay-verify="required" placeholder="请输入.." autocomplete="off" class="layui-input cwid">
                    </div>
                </div>
            </td>
            <td>
                <div class="layui-form-item" style="width: 280px;">
                    <label style="width: 130px;" class="layui-form-label">基金名称</label>
                    <div class="layui-input-block">
                        <input type="text" style="width: 150px;" name="fName" required lay-verify="required" placeholder="请输入.."  autocomplete="off" class="layui-input zrxm">
                    </div>
                </div>
            </td>
            <td>
                <div class="layui-form-item" style="width: 280px;">
                    <label style="width: 130px;" class="layui-form-label">单位净值</label>
                    <div class="layui-input-block">
                        <input type="text" style="width: 150px;" name="dwjz" required lay-verify="required" placeholder="请输入.." autocomplete="off" class="layui-input cwzl">
                    </div>
                </div>
            </td>
            <td>
                <div class="layui-form-item" style="width: 280px;">
                    <label style="width: 130px;" class="layui-form-label">是否能够代销</label>
                    <div class="layui-input-block">
                        <input type="text" style="width: 150px;" name="ifBuy" required lay-verify="required" placeholder="请输入.." autocomplete="off" class="layui-input ylxm">
                    </div>
                </div>
            </td>
            <td>
                <button type="button" id="searchTable" class="layui-btn layui-btn-primary" style="margin:0 0 16px 19px;border-radius:7px;">
                    <i class="layui-icon">&#xe615;</i></button>
            </td>
        </tr>
    </table>
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit" style="background:#BEBFAD"><i class="layui-icon">&#xe642;编辑</i></a>
</script>
<script type="javascript">
    $('.layui-none', $(this.elem).next()).width($('.layui-table-header table', $(this.elem).next()).width() + 'px');
</script>
<script src="Resource/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use('table', function(){
        var table = layui.table;
        table.render({
            elem: '#test'
            ,url:'./selectFundAll'
            ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }],
            limits: [3, 5, 10, 20],
            limit: 12,
            method: "POST",
            id:'testReload',
            request: {
                pageName: 'pageNum',
                limitName: 'pageSize'
            }
            ,title: '用户数据表'
            ,cols: [
                [{
                    type: 'checkbox',
                    fixed: 'left'
                },
                    {
                        field: 'fId',
                        title: '基金编号',
                        align: 'center',
                        width:100
                    },
                    {
                        field: 'fName',
                        title: '基金名称',
                        align: 'center',
                        width:200
                    },
                    {
                        field: 'beforeRate',
                        title: '原费率',
                        align: 'center',
                        width:100
                    },
                    {
                        field: 'afterRate',
                        title: '现费率',
                        align: 'center',
                        width:100
                    },
                    {
                        field: 'minBuy',
                        title: '最小申购额',
                        align: 'center',
                        width:100,
                    },
                    {
                        field: 'stockCode',
                        title: '持仓股票代码',
                        align: 'center',
                        width:200
                    },
                    {
                        field: 'sy1n',
                        title: '一年收益',
                        align: 'center',

                        width:100
                    },
                    {
                        field: 'sy6y',
                        title: '六月收益',
                        align: 'center',
                        width:100
                    },
                    {
                        field: 'sy3y',
                        title: '三月收益',
                        align: 'center',
                        width:100
                    },
                    {
                        field: 'sy1y',
                        title: '一月收益',
                        align: 'center',
                        width:100
                    },
                    {
                        field: 'dwjz',
                        title: '单位净值',
                        align: 'center',
                        width:100
                    },
                    {
                        field: 'dwgz',
                        title: '单位估值',
                        align: 'center',
                        width:100
                    },
                    {
                        field: 'endTime',
                        title: '数据截止日期',
                        align: 'center',
                        width:180
                    },
                    {
                        field: 'valuationTime',
                        title: '估值时间',
                        align: 'center',
                        width:180
                    },
                    {
                        field: 'nowWorth',
                        title: '实时净资产',
                        align: 'center',
                        width:100
                    },
                    {
                        field: 'ifBuy',
                        title: '是否能够代销',
                        align: 'center',
                        width:100
                    },
                    {
                        fixed: 'right',
                        title: '操作',
                        align: 'center',
                        toolbar: '#barDemo',
                        width: 100,
                    },
                ]]
            ,page: true,
            parseData: function(res) { //res 即为原始返回的数据
                console.log(res);
                var current_pages;
                //第一次显示的时候this.page=true，把这种情况单独列出
                if (this.page === true) current_pages = 1;
                else current_pages = this.page.curr;
                //根据分页要求选出需要显示的数据
                var data = res.data.slice(this.limit * (current_pages - 1), this.limit * current_pages);
                return {
                    "code": res.code,
                    "msg": res.msg,
                    "count": res.data.length,
                    "data": data
                }
            }
        });
        //监听行工具事件
        table.on('tool(test)', function(obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            var jsonData = JSON.stringify(data);
            if (layEvent === 'edit') {
                layer.open({
                    title:"<div style='    width: 1000px;\n" +
                        "    background: #364150;\n" +
                        "    margin-left: -20px;\n" +
                        "    color: white;padding-left: 20px;'>基金信息修改</div>",
                    type: 1,
                    skin:"xgtc",
                    area: ['830px', '615px'],
                    offset:['10px','200px'],
                    content: $('#xgdiv'),
                    success: function(layero, index) {
                        $("#edit_fId").val(data.fId);
                        $("#edit_fName").val(data.fName);
                        $("#edit_beforeRate").val(data.beforeRate);
                        $("#edit_afterRate").val(data.afterRate);
                        $("#edit_minBuy").val(data.minBuy);
                        $("#edit_stockCode").val(data.stockCode);
                        $("#edit_sy1n").val(data.sy1n);
                        $("#edit_sy6y").val(data.sy6y);
                        $("#edit_sy3y").val(data.sy3y);
                        $("#edit_sy1y").val(data.sy1y);
                        $("#edit_dwjz").val(data.dwjz);
                        $("#edit_dwgz").val(data.dwgz);
                        $("#edit_endTime").val(data.endTime);
                        $("#edit_valuationTime").val(data.valuationTime);
                        $("#edit_nowWorth").val(data.nowWorth);
                        $("#edit_ifBuy").val(data.ifBuy);
                    },
                });
            };
        });
        $('body').on('click', '#searchTable', function() {
            var input1 = $(".cwid").val();
            var input2 = $(".zrxm").val();
            var input3 = $(".cwzl").val();
            var input4 = $(".ylxm").val();
            table.reload('testReload', {
                url: './conditionSelectFund',
                request: {
                    pageName: 'pageNum',
                    limitName: 'pageSize'
                },
                where: {
                    fId: input1,
                    fName: input2,
                    dwjz : input3,
                    ifBuy: input4
                },
                page: {
                    curr: 1
                }
            });
        });
    });
</script>
</body>
</html>